import { modal } from 'vue-strap'
import { showMsg, swapGolds } from '../../../vuex/action'
export default {
  components: {
    'vue-modal': modal
  },
  data() {
    return {
      showChangeModal: false,
      fromBetaId: '',
      toBetaId: ''
    }
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xSwapGolds: swapGolds
    }
  },
  methods: {
    submit() {
      if (!this.fromBetaId || !this.toBetaId) {
        return this.xShowMsg({
          type: 'danger',
          content: '* 标记的均为必填/必选项'
        })
      }
      this.xSwapGolds({
        fromBetaId: this.fromBetaId,
        toBetaId: this.toBetaId
      })
        .then(() => {
          this.$els.swapForm.reset()
          this.showChangeModal = false
        })
        .catch((res) => {
          this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  }
}
